package cn.shengchao.rule.engine;

import cn.shengchao.rule.condition.matchType.*;
import cn.shengchao.rule.condition.paramKey.*;
import cn.shengchao.rule.condition.valueType.*;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @program: examstarapi
 * @description: 规则元素容器
 * @author: Xiong weiqiang
 * @create: 2025-04-11 15:05
 */
public class RuleElementContainer {
    public static ConcurrentHashMap<String, IValueType> valueTypeConcurrentHashMap=new ConcurrentHashMap<>();
    public static ConcurrentHashMap<String, IMatchType> matchTypeConcurrentHashMap=new ConcurrentHashMap<>();
    public static ConcurrentHashMap<String, IConditionParamKey> conditionParamKeyConcurrentHashMap=new ConcurrentHashMap<>();

    static{
        valueTypeConcurrentHashMap.put(IValueType.TYPE_INTEGER,new IntegerValueType());
        valueTypeConcurrentHashMap.put(IValueType.TYPE_DAY,new DayValueType());
        valueTypeConcurrentHashMap.put(IValueType.TYPE_DATE,new DateValueType());
        valueTypeConcurrentHashMap.put(IValueType.TYPE_STRING,new StringValueType());
        valueTypeConcurrentHashMap.put(IValueType.TYPE_DOUBLE,new DoubleValueType());
        valueTypeConcurrentHashMap.put(IValueType.TYPE_ARRAY,new ArrayValueType());


        matchTypeConcurrentHashMap.put(IMatchType.EQUALS,new MatchTypeEquals());
        matchTypeConcurrentHashMap.put(IMatchType.DATE_RANGE_IN,new MatchTypeDateRangeIn());
        matchTypeConcurrentHashMap.put(IMatchType.IN_ARRAY,new MatchTypeInArray());
        matchTypeConcurrentHashMap.put(IMatchType.GREATER_THAN,new MatchTypeGreaterThan());
        matchTypeConcurrentHashMap.put(IMatchType.GREATER_AND_EQUALS,new MatchTypeGreaterEquals());
        matchTypeConcurrentHashMap.put(IMatchType.LESS_THAN,new MatchTypeLessThan());
        matchTypeConcurrentHashMap.put(IMatchType.LESS_AND_EQUALS,new MatchTypeLessEquals());

        //条件参数定义
        conditionParamKeyConcurrentHashMap.put(IConditionParamKey.ENTRY_URI,new EntryUriConditionParamKey());
        conditionParamKeyConcurrentHashMap.put(IConditionParamKey.PRODUCT_ID,new ProductConditionParamKey());
        conditionParamKeyConcurrentHashMap.put(IConditionParamKey.REGISTER_DATE_RANGE,new RegisterDateRangeParamKey());
        conditionParamKeyConcurrentHashMap.put(IConditionParamKey.VIP_LEVELS,new UserVipLevelParamKey());
        conditionParamKeyConcurrentHashMap.put(IConditionParamKey.USER_SOURCE_CHANNEL,new UserSourceChannelParamKey());


    }

    public static IValueType getValueType(String valueTypeKey){
        return valueTypeConcurrentHashMap.get(valueTypeKey);
    }

    public static IMatchType getMatchType(String matchTypeKey){
        return matchTypeConcurrentHashMap.get(matchTypeKey);
    }

    public static IConditionParamKey getConditionParamKey(String conditionParamKey){
        return conditionParamKeyConcurrentHashMap.get(conditionParamKey);
    }

}